package com.yoomiito.app.adapter.home.reommend;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.yoomiito.app.R;
import com.yoomiito.app.model.bean.EmptyInfo;
import com.yoomiito.app.utils.DensityUtil;

public class EmptyAdapter extends DelegateAdapter.Adapter<RecyclerView.ViewHolder>  {

    private Context mContext;
    private EmptyInfo mEmptyInfo;
    private int size = 0;
    public EmptyAdapter(Context context,EmptyInfo emptyInfo) {
        mContext = context;
        this.mEmptyInfo = emptyInfo;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return new LinearLayoutHelper();
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.layout_empty_1,parent,false);
        RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
        lp.rightMargin = DensityUtil.dp2px(12);
        lp.leftMargin  = DensityUtil.dp2px(12);
        view.setLayoutParams(lp);
         return new ItemViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
        itemViewHolder.mImageView.setImageResource(mEmptyInfo.getIvResId());
        itemViewHolder.mContentTv.setText(mEmptyInfo.getContent_1());
        itemViewHolder.mContent_2Tv.setText(mEmptyInfo.getContent_2());
    }

    @Override
    public int getItemCount() {
        return size;
    }

    @Override
    public int getItemViewType(int position) {
        return 10;

    }

    public void setSize(int size) {
        this.size = size;
    }

    private class ItemViewHolder extends RecyclerView.ViewHolder{
        private TextView mContent_2Tv;
        private TextView mContentTv;
        private ImageView mImageView;
        public ItemViewHolder(View itemView) {
            super(itemView);
            mImageView = itemView.findViewById(R.id.empty_iv);
            mContentTv = itemView.findViewById(R.id.empty_content_1);
            mContent_2Tv = itemView.findViewById(R.id.empty_content_2);
        }
    }

}
